package xuhaijia.lanou3g.autohome.find.groupbuy;
//                .-~~~~~~~~~-._       _.-~~~~~~~~~-.
//            __.'              ~.   .~              `.__
//          .'//                  \./                   \\`.
//        .'//            为什么坚持  想一想当初             \\`.
//      .'// .-~"""""""~~~~-._     |     _,-~~~~"""""""~-.  \\`.
//    .'//.-"                 `-.  |  .-'                 "-. \\`.
//  .'//______.============-..   \ | /   ..-============._______\\`.
//.'//____________________________\|/_____________________________\\`.
// 
//                             

import android.Manifest;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import xuhaijia.lanou3g.autohome.R;
import xuhaijia.lanou3g.autohome.activity.WebViewActivity;
import xuhaijia.lanou3g.autohome.base.BaseActivity;
import xuhaijia.lanou3g.autohome.base.NetTool;
import xuhaijia.lanou3g.autohome.base.URLValues;

/**
 * Created by 7 on 16/8/29.
 */
public class GroupBuyActivity extends BaseActivity {

    private ListView lv;
    private GroupBuyAdapter groupBuyAdapter;

    @Override
    protected int setLayout() {
        return R.layout.activity_groupbuy;
    }

    @Override
    protected void initView() {
        lv = bindView(R.id.activity_groupbuy_lv);
    }

    @Override
    protected void initData() {
        groupBuyAdapter = new GroupBuyAdapter(this);
        mNetTool.getNetData(URLValues.GROUP_BUY_URL, GroupBuyBean.class, new NetTool.NetListener<GroupBuyBean>() {
            @Override
            public void onSuccess(final GroupBuyBean groupBuyBean) {
                groupBuyAdapter.setGroupBuyBean(groupBuyBean);
                lv.setAdapter(groupBuyAdapter);
                lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                    @Override
                    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                        Intent intent = new Intent();
                        intent.putExtra("url" , groupBuyBean.getResult().getActivitylist().get(position).getUrl());
                        intent.setClass(GroupBuyActivity.this , WebViewActivity.class);
                        startActivity(intent);
                    }
                });
            }

            @Override
            public void onError(String errorMsg) {

            }
        });
    }

}
